package com.campus.controller;

import com.campus.dao.SysUserMapper;
import com.campus.entry.SysUser;
import com.campus.exception.BusinessException;
import com.campus.pojo.dto.AccountDto;
import com.campus.response.ResponseResult;
import com.campus.response.ResultCode;
import com.campus.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.Objects;


@RestController
@RequestMapping("/account")
public class AccountController {
    @Autowired
    private AccountService accountService;
    @PostMapping("/login")
    public ResponseResult<Map<String,String>> login(@RequestBody AccountDto accountDto){
        if (Objects.isNull(accountDto.getLoginName())){
            throw new BusinessException(ResultCode.ERROR);
        }
        Map<String, String> login = accountService.login(accountDto);
        return new ResponseResult<>(ResultCode.ALL_SUCCESS,login);
    }
}
